Home:ALL Converter>Mongo invalid document for insert: keys cannot begin with "$": "$date"

Mongo invalid document for insert: keys cannot begin with "$": "$date"

Ask Time:2022-05-08T04:53:26         Author:Bogdan Dubyk

Json Formatter

I'm working on a script that is moving some documents from one collection to another, so if a document met the needed criteria I'm inserting it into another collection and removing it from the original collection. And one document failed with the error invalid document for insert: keys cannot begin with "$": "$date" because it has an field like:

   "rerender_at" : {
        "$date" : {
            "$numberLong" : "1485872000000"
        }
    },

But if mongo does not allow to insert of fields with $ how it's possible that the document has that data already??? Or if it's possible to insert, how can I do it???

Referring to this topic it's not allowed to insert

Author:Bogdan Dubyk,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72156298/mongo-invalid-document-for-insert-keys-cannot-begin-with-date
yy